using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SmartLink.WebApi.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";
            return View();
        }

        public ActionResult DictionaryCategorys()
        {
            var dictionary = new Dictionary<string, string>();
            var categorys = typeof(Infrastructure.DictionaryConst).GetFields();
            foreach (var category in categorys)
            {
                var dscpAttr = category.GetCustomAttributes(typeof(DescriptionAttribute), false);
                if (dscpAttr != null && dscpAttr.Length > 0)
                {
                    var description = ((DescriptionAttribute)dscpAttr[0]).Description;
                    dictionary.Add(category.GetValue(null).ToString(), description);
                }
            }
            return View(dictionary);
        }
    }
}
